let electron =require('electron')
let app=electron.app
let BrowserWindow=electron.BrowserWindow;
let win=null

app.on('ready',function () {
    win=new BrowserWindow({
        webPreferences:{
            nodeIntegration:true
        }
    });
    let path=require('path');
    let URL=require('url');
    let url='';
    if(process.env.NODE_ENV!=='production'){
        url='http://localhost:'+process.env.ELECTRON_WEBPACK_WDS_PORT;
    }else {
        url=URL.format({
            pathname:path.join(__dirname,'index.html'),
            protocol:'file'
        })
    }
    win.loadURL(url)

    win.on('closed',function (){
        win=null
    })
})
app.on('window-all-closed',function () {
    app.quit()
})